package cn.kvchoi.proactor_aio;

import cn.kvchoi.proactor_aio.server.ProactorInitiator;

import java.io.IOException;

/**
 * AIO & Proactor pattern server
 */
public class ProactorServer {

    static int ASYNC_SERVER_PORT = 4333;

    public static void main(String[] args) {
        try {
            System.out.println("Async server listening on port : " + ASYNC_SERVER_PORT);
            new ProactorInitiator().initiateProactiveServer(ASYNC_SERVER_PORT);
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Because of totally asynchronous, should sleep indefinitely since otherwise the JVM would terminate
        while (true) {
            try {
                Thread.sleep(Long.MAX_VALUE);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
